package com.examples.demo2;

import com.google.inject.Guice;
import com.google.inject.Inject;
import lombok.val;

/**
 * 通过构造器注入
 */
public class ConstructorInjectDemo {

    private Service service;

    public Service getService() {
        return service;
    }

    @Inject
    public ConstructorInjectDemo(Service service) {
        this.service = service;
    }

    public static void main(String[] args) {
        val c = Guice.createInjector().getInstance(ConstructorInjectDemo.class);
        c.getService().execute();
    }
}
